@extends('Admin.layouts.common')

@section('content')
    <div class="container myContainer">
        <form method="post">
            {{ csrf_field() }}
            <div class="form-group">
                <h3 class="form-group-static">{{ $admin_info['username'] }}</h3>
            </div>
            
            <div class="form-group required">
                <label class="control-label">分组</label>
                <select class="form-control" name="group_id">
                    
                    @foreach($group as $c)
                        <option value="{{ $c->id}}" @if($c->id==$admin_info['group_id']) selected="" @endif >{{ $c->group_name}}</option>
                    @endforeach
                </select>
            </div>
            
            <div class="form-group">
                <label class="control-label">权限设置 <button type="button" onclick="$('input').iCheck('check');">全选</button> <button type="button" onclick="$('input').iCheck('toggle');">反选</button></label>
                @foreach($admin_option_list as $root_menu => $r )
                    <h5 class="rights_title">{{ $root_menu }}：<button type="button" onclick="$('.{{$root_menu}}').find('input').iCheck('check');">全选</button> <button type="button" onclick="$('.{{$root_menu}}').find('input').iCheck('toggle');">反选</button></h5>
                    <div class="{{$root_menu}}">
                    @foreach($r as $rights => $menu)
                        <label class="rights_checkbox">
                            {{ $menu }}
                            <input type="checkbox" name="rights[]" value="{{ $rights }}" {{ in_array($rights, $admin_info['rights']) ? 'checked' : '' }}>
                        </label>
                    @endforeach
                    </div>
                @endforeach
            </div>
            <div><hr></div>
            <div class="form-group">
                <label class="control-label">文章审核</label>

                <h5 class="rights_title">可以审核文章分类：<button type="button" onclick="$('.cats').find('input').iCheck('check');">全选</button> <button type="button" onclick="$('.cats').find('input').iCheck('toggle');">反选</button></h5>
                    <div class="cats">
                    @foreach($cats as $r)
                        <label class="rights_checkbox">
                            {{$r->name}}
                            <input type="checkbox" name="article_cats[]" value="{{ $r->id }}" {{ in_array($r->id, $admin_info['article_cats']) ? 'checked' : '' }}>
                        </label>
                    @endforeach
                    </div>
            </div>

            <div class="form-group">
                <label class="control-label">视频审核</label>

                <h5 class="rights_title"> 可以审核视频分类：<button type="button" onclick="$('.cats').find('input').iCheck('check');">全选</button> <button type="button" onclick="$('.cats').find('input').iCheck('toggle');">反选</button></h5>
                    <div class="cats">
                    @foreach($video_cats as $r)
                        <label class="rights_checkbox">
                            {{$r->name}}
                            <input type="checkbox" name="video_cats[]" value="{{ $r->id }}" {{ in_array($r->id, $admin_info['video_cats']) ? 'checked' : '' }}>
                        </label>
                    @endforeach
                    </div>
            </div>

            <div class="form-group">
                <button class="btn btn-primary btn-block" type="submit">修改</button>
            </div>
        </form>
    </div>
@endsection